using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class VelocityMinus : StateMachineBehaviour
{
    public float minusSpeed;

    private Rigidbody2D rigidbody;
    private Character character;
    private Vector2 currentVel;
    public override void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    {
        rigidbody = animator.GetComponentInParent<Rigidbody2D>();
        character = animator.GetComponentInParent<Character>();
        currentVel = rigidbody.velocity;
    }

    public override void OnStateMove(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    {
        currentVel.x -= minusSpeed * character.GetScaleX();
        rigidbody.velocity = new Vector2(currentVel.x, 0);
        Debug.Log(rigidbody.velocity);

    }

    public override void OnStateExit(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    {
        rigidbody.velocity = new Vector2(0, 0);
        character.Run = false;
    }



}
